Magento 2 Development Quick Start Guide by Branko Ajzele

Magento 2 Development Quick Start Guide by Branko Ajzele

Author:Branko Ajzele
Language: eng
Format: epub
Tags: COM060170 - COMPUTERS / Web / Content Management Systems, COM064000 - COMPUTERS / Electronic Commerce (see also headings underBUSINESS and ECONOMICS / E-Commerce), COM060160 - COMPUTERS / Web / Web Programming
Publisher: Packt Publishing
Published: 2018-09-20T09:47:30+00:00


Understanding search criteria

The searchCriteria parameter of a GET request allows for search results filtering. The key to using it comes down to understanding its structure and the available condition types.

Observing the \Magento\Framework\Api\SearchCriteriaInterface interface, and the Magento\Framework\Api\SearchCriteria class as its concrete implementation, we can easily conclude the following search_criteria structure:

"search_criteria": {

"filter_groups": [],

"current_page": 1,

"page_size": 10,

"sort_orders": []

}

Whereas the mandatory filter_groups parameter and its structure are shown as follows:

"filter_groups": [

{

"filters": [

{

"field": "fieldOrAttrName",

"value": "fieldOrAttrValue",

"condition_type": "eq"

},

{

// Logical OR

}

]

},

{

// Logical AND

}

],

Conditions nested under the individual filters key, correspond to the Logical OR condition.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.